<?php
namespace app\admin\logic;
use app\admin\code\BaseCode;
use app\admin\model\AdModel;
use app\admin\model\ArticleModel;
use think\Lang;

class ArticleLogic extends BaseLogic
{
    protected function _after_del_validate(){
        $model = new ArticleModel();
        if($model->deleteTrue(['id'=>$this->_param['id']])){
            $this->result = true;
            return true;
        }else{
            $this->err = ['code'=>BaseCode::FAIL,'msg'=>Lang::get(BaseCode::FAIL)];
            $this->result = false;
            return false;
        }
    }
    protected function _after_update_validate(){
        $model = new ArticleModel();
        $where = [];
        $where['id'] = $this->_param['id'];
        unset($this->_param['id']);
        if($model->updateData($where,$this->_param)){
            $this->result = true;
            return true;
        }else{
            $this->err = ['code'=>BaseCode::FAIL,'msg'=>Lang::get(BaseCode::FAIL)];
            $this->result = false;
            return false;
        }
    }
    protected function _after_add_validate()
    {
        $model = new ArticleModel();
        return $model->addData($this->_param);
    }
}


